package com.leyou.common.pojo.test;

import com.fasterxml.jackson.core.type.TypeReference;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;

import static com.leyou.common.utils.JsonUtils.nativeRead;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
    String name;
    Integer age;

    public static void main(String[] args) {
        User user = new User("Jack", 21);
        //一个数组中有两个对象
        String json = "[{\"name\":\"Jack\", \"age\": \"21\"}, {\"name\":\"Rose\", \"age\": \"18\"}]";
        //List里面嵌套一层Map,里面是两个Map对象
        List<Map<String, String>> maps = nativeRead(json, new TypeReference<List<Map<String, String>>>() {
        });

        for (Map<String, String> map : maps) {
            System.out.println("map = " + map);
        }
    }
}